﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TaskOptions.aspx.cs" Inherits="com.vs.RF.Web.task.TaskOptions" MasterPageFile="~/RF.Master" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="com.vs.DataAccess" %>

<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="server">
    <script language="javascript" type="text/javascript">
    
        <%
            string stLink = null;
            if (null != this.dtPref && dtPref.Rows.Count > 0) 
            { 
        %>
        var actions = new Array(<%= dtPref.Rows.Count %>);
        <%
                for (int i=0; i<dtPref.Rows.Count; i++){
                    stLink = DataManager.GetString(dtPref.Rows[i], "PREFERENCE_NAME");
        %>
        actions[<%= i %>] = "<%= stLink %>";
        <%
                }
            }
        %>
        
        function btnOK_Click() {
            var iChoice = form1.tbChoice.value;
            if (iChoice > <%= dtPref.Rows.Count %>){
                alert("选项不存在");
                return;
            }
            else{
                form1.hdTaskPref.value = actions[iChoice - 1];
                form1.submit();
            }
        }

        function btnCancel_Click() {
            form1.action = "../login/Main.aspx";
            form1.submit();
        }
        
        function on_Load(){
            form1.tbChoice.focus();
        }
        
        function on_KeyDown(){
            if(event.keyCode == "13")
                btnOK_Click();
        }
    </script>

     <%= stErrorMessage %>
    <form id="form1" method="post" action="TaskOptionsEntryHandling.aspx" onkeydown="on_KeyDown()">
    <input type="hidden" name="hdTaskPref" />
    <div>    
        <table>
            <tr>
                <td>选择：</td>
                <td><input type="text" name="tbChoice" class="greyRed" /></td>
            </tr>
            <%
                if (null != dtPref && dtPref.Rows.Count > 0)
                {
                    int iIdx = 0;
                    foreach (DataRow dr in dtPref.Rows)
                    {
                        iIdx++;
                        string stPrefName = DataManager.GetString(dr, "PREFERENCE_NAME");
            %>
            <tr>
                <td><%=iIdx%></td>
                <td>
                    <a href="javascript:form1.hdTaskPref.value='<%=stPrefName %>'; form1.submit();"><%=stPrefName%></a>
                </td>
            </tr>
            <%
                    }
                }
            %>
        </table>
    </div>  
    <div id="footer">  
        <input type="button" id="btnOK" value="确定" onclick="btnOK_Click()" class="greyRed"/>
        <input type="button" id="btnCancel" value="取消" onclick="btnCancel_Click()" class="greyRed" />
    </div>
    </form>
</asp:Content>